home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / edit / mg2a_src.zip / SYS / OSK / SPAWN.C < prev    next >
C/C++ Source or Header  |  1988-08-23  |  1KB  |  48 lines

  1. /*
  2.  * Name:    MicroGnuEmacs
  3.  *        OS9/68k Spawn Shell
  4.  */
  5. #include    "def.h"
  6.  
  7. #include    <sgstat.h>
  8.  
  9. extern    struct    sgbuf    oldtty;        /* There really should be a    */
  10. extern    struct    sgbuf    newtty;        /* nicer way of doing this    */
  11.  
  12. spawncli(f, n)
  13. {
  14.     register int    pid;
  15.     register int    wpid;
  16.     int        status;
  17.     register char    *cp;
  18.     int        os9fork();
  19.     static char    *argv[2] = {"shell", NULL};
  20.     extern char    **environ;
  21.     char        *getenv();
  22.  
  23.     ttcolor(CTEXT);
  24.     ttnowindow();
  25.     ttmove(nrow-1, 0);
  26.     if (epresf != FALSE) {
  27.         tteeol();
  28.         epresf = FALSE;
  29.     }
  30.     ttflush();
  31.     if((cp=getenv("SHELL")) != NULL) argv[0] = cp;
  32.     if(_ss_opt(0, &oldtty) == -1) {
  33.         ewprintf("_ss_opt #1 to terminal failed");
  34.         return FALSE;
  35.     }
  36.     if((pid=os9exec(os9fork, argv[0], argv, environ, 0, 0)) == -1) {
  37.         ewprintf("Failed to create process");
  38.         return FALSE;
  39.     }
  40.     while ((wpid=wait(&status))>=0 && wpid!=pid) {}
  41.     sgarbf = TRUE;                /* Force repaint.    */
  42.     if(_ss_opt(0, &newtty) == -1) {
  43.         ewprintf("_ss_opt #2 to terminal failed");
  44.         return FALSE;
  45.     }
  46.     return TRUE;
  47. }
  48.